home *** CD-ROM | disk | FTP | other *** search
/ Merciful 4 / Merciful - Disc 4.iso / software / p / psychotoads.dms / psychotoads.adf / a78 < prev    next >
Text File  |  1989-03-31  |  51KB  |  1,675 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                          7:CONTROL STRUCTURES                               73
  9.                       --------------------------
  10.  
  11.  
  12.                    GOTO (jump to a new line number)
  13.  
  14. The action of GOTO is to transfer the control of the program one place
  15. to another. There are three forms of the GOTO command allowes in AMOS;
  16.  
  17.         GOTO label
  18.  
  19. "label" is an optional place marker at the side of a line. Label names
  20. are defined using the ":" colon character like so: 
  21.  
  22.         label:
  23.  
  24. The label name can consist of any string of alphanumeric characters you
  25. like, including "-". It's constructed using the same rules which apply
  26. for variables and procedure names.
  27.  
  28.         GOTO line number
  29.  
  30. Any AMOS Basic line can be optionally preceded with a number. These
  31. line numbers are included solely for compatibility purposes with other
  32. versions of Basic (such as STOS for the Atari ST). It's better to rely
  33. on labels instead, as these are much easier to read and remember.
  34.  
  35.         GOTO variable
  36.  
  37. Variable can be any allowable AMOS Basic expression. This expression
  38. may be either a normal ingerer or a string. Integers run a line number
  39. for your GOTO, whereas strings hold the name of a label. 
  40.  
  41.   Technically speaking, this construction is known as a computed goto.
  42. It's generally growned upon by serious programmers, but it can be
  43. incredibly useful at times. Examples:
  44.  
  45.         ROOM=3
  46.         BEGIN:
  47.         Goto "ROOM"+Str$(ROOM)-" "
  48.         End
  49.         ROOM3:
  50.         Print "Room three!"
  51.         Goto BEGIN
  52.  
  53.  
  54.  
  55.                      GOSUB (jump to a subroutine)                           74
  56.  
  57. GOSUB is another outmoded instruction, and provides you with the useful
  58. ability to split a program into smaller, more manageable chunks, known
  59. as subroutines. Nowadays, GOSUB has been almost entirely supplanted by
  60. AMOS Basic's procedure system. However, GOSUB does form a useful
  61. half-way house when you're converting programs from another version of
  62. Basic such as STOS.
  63.  
  64.   As with GOTO, there are three different forms of the GOSUB
  65. instruction.
  66.  
  67.         GOSUB n         Jump to the subroutine at line n
  68.  
  69.         GOSUB name      Jump to an AMOS label
  70.  
  71.         GOSUB exp       Jump to a label or line which results from the
  72.                         expression in "exp".
  73.  
  74.         Example:
  75.  
  76.         For I=1 To 10
  77.           Gosub TEST
  78.         Next I
  79.         Direct
  80.         TEST:
  81.         Print "This is an example of GOSUB":Print "I equals ";I
  82.         Return: Rem Exit from subroutine TEST and return to main prg.
  83.  
  84. It's good practice to always plave your subroutines at the end of your
  85. main program as this makes them easier to pick out from your program
  86. listings. You should also add a statement like EDIT or DIRECT to end of
  87. your main program, as otherwise AMOS may attempt to execute your GOSUBs
  88. after the program has finished, generating an error message.
  89.  
  90.  
  91.  
  92.                    RETURN (return from a subroutine)
  93.  
  94. RETURN
  95.  
  96. RETURN exits from a subroutine which was previously entered using
  97. GOSUB. It immediately jumps back to the next Basic instruction after
  98. the original GOSUB.
  99.  
  100.   Note that a single GOSUB statement can contain several RETURN
  101. commands. So you can exit from any number of different points in your
  102. routine depending on the situation.
  103.  
  104.  
  105.  
  106.               POP (remove the RETURN info after a GOSUB)                    75
  107.  
  108. POP
  109.  
  110. Normally it's illegal to exit from a GOSUB statement using a standard
  111. GOTO. This can occassionally be inconvenient, especially if an error
  112. occurs, which makes in unacceptable to return to your program from the
  113. precice point you left it.
  114.  
  115.   The POP instruction removes the return address generated by your
  116. GOSUB, and allows you to leave the subroutine in any way you like,
  117. without first having to execute the final RETURN statement. Example:
  118.  
  119.         Do
  120.           Gosub TEST
  121.         Loop
  122.         BYE:
  123.         Print "Popped Out"
  124.         Direct :  
  125.         TEST:
  126.         Print "Hi there!"
  127.         If Mouse Key Then Pop : Goto BYE
  128.         Return
  129.  
  130.  
  131.  
  132.  
  133.         IF...THEN...[ELSE] (coose between alternative actions)              76
  134.  
  135. The IF...THEN instruction allows you to make simple decisions within a
  136. Basic program. The format is:
  137.  
  138. IF conditions THEN statements 1 [ELSE statements 2]
  139.  
  140. "conditions" can be any list of tests including AND and OR. Statements
  141. 1 and Statements 2 must be a list of AMOS Basic instructions. If you
  142. want to jump to a line number or a label, you'll have to include a
  143. separate GOTO command like so:
  144.  
  145.         If test Then Goto Label : This is fine.
  146.                      ----
  147. If you forget about this, and leave the "Goto", you'll get an error
  148. message "procedure not defined".
  149.  
  150.         If test Then Label : Rem THIS CALLS A *PROCEDURE*
  151.  
  152. The scope of this IF...THEN statement is limited to just a single line
  153. of your Basic program. It has now been superceded by the much more
  154. powerful IF...ELSE...ENDIF command.
  155.  
  156.  
  157.  
  158.                  IF...[ELSE]...ENDIF (structured test)
  159.  
  160. Although the original form of IF...THEN is undoubtedly useful, it's
  161. rather old fashioned when compared with the facilities found in a
  162. really modern version of Basic such as AMOS. This allows you to execute
  163. whole lists of instructions depending on the outcome of a single test.
  164.  
  165.         IF tests=TRUE
  166.           <List of statements 1>
  167.                "       "
  168.         ELSE
  169.           <List of statements 2>
  170.                "       "
  171.         ENDIF
  172.  
  173. Note: it's illegal to use a normal IF...THEN inside a structured test!
  174. These should be replaced by their equivalent IF...ENDIF instruction ;
  175.  
  176.         If test Then Goto Label Else Label2
  177.  
  178. This now becomes:
  179.  
  180.         If test : Goto Label : Else goto Label2 : Endif
  181.  
  182. or:
  183.  
  184.         If test
  185.           Goto Label
  186.         Endif
  187.  
  188. Here is an example of the IF...ENDIF statement in action:
  189.  
  190.         Input "Enter values for a,b and c";A,B,C
  191.         If A=B
  192.           Print "Equal"
  193.         ELSE
  194.           Print "Different";
  195.           If A<>B and A<>C
  196.             Print ", and C is not the same too!"
  197.           Endif
  198.         End if
  199.  
  200. Each IF statement in your program MUST be paired with a single ENDIF
  201. command as this informs AMOS Basic precisely which group of
  202. instructions are to be executed inside your test.
  203.  
  204. Note that "THEN" is not used by this form of the instruction at all.
  205. This may take a little getting used to if you are already experienced
  206. with one of the other versions of Basic for the Commodore Amiga.
  207.  
  208.  
  209.  
  210.                 FOR...NEXT (repeat a section of a code                      77
  211.                       a specific number of times)
  212.  
  213. FOR index=first TO last [STEP inc]
  214. <list of instructions>
  215.          "
  216. NEXT [index]
  217.  
  218. "Index" holds a counter which will be incremented after each and every
  219. loop. At the start of the loop, this counter will be loaded with the
  220. result of the expression "first". The instructions between FOR and the
  221. NEXT are now performed until the NEXT is reached.
  222.  
  223.   "inc" is a value which will be added to the counter after each loop 
  224. by the NEXT instruction. If this is omitted, the increment will be
  225. automatically set to 1.
  226.  
  227.   Note that if "inc" is negative, the loop will be halted when the
  228. counter is less than the value in "first". So the entire loop will be
  229. performed in reverse.
  230.  
  231.   Once inside loop, "index" can be read from your program just like a
  232. normal variable. But you are *NOT* allowed to change its value in any
  233. way as this will generate an error message.
  234.  
  235.   Each FOR statement in your program MUST be matched by a single NEXT
  236. instruction. You can't use the shorthand forms found in other Basics
  237. like NEXT R1,R1. Here are a couple of examples of these loops:
  238.  
  239.         For I=32 to 255 : Print Chr$(I);:Next I
  240.  
  241.         For R1=20 to 100 Step 20
  242.           For R2=20 to 100 Step 20
  243.             For A=0 To 3
  244.               Ink A
  245.               Ellipse 160,100,R1,R2
  246.             Next A
  247.           Next R2
  248.         Next R1
  249.  
  250.  
  251.  
  252.                    WHILE...WEND (repeat a section of                        78
  253.                     code while a condition is true)
  254.  
  255. WHILE condition
  256.   :     :
  257. list of statements
  258.   :     :
  259. WEND
  260.  
  261. "condition" can be any set of tests you like and can include the
  262. constructions AND, OR and NOT. A check is made on each turn of the
  263. loop. If the test returns a value of -1 (true), then the statements
  264. between the WHILE and WEND will be executed, otherwise the loop will be
  265. aborted and Basic will proceed to the next insturction. Type the
  266. following example:
  267.  
  268.         Input "Type in a number";X
  269.         Print "Counting to 11"
  270.         While X<11
  271.           Inc X
  272.           Print X
  273.         Wend
  274.         Print "Loop terminated"
  275.  
  276. The number of times WHILE loop in this program will executed depends on
  277. the value you input to the routine. If you enter a number larger than
  278. 10, the loop will never be executed at all. WHILE will therefore only
  279. execute the statements if the condition is TRUE at the start of your
  280. program.
  281.  
  282.  
  283.  
  284.         REPEAT...UNTIL (repeat until a condition is satisfied)
  285.  
  286. REPEAT
  287.  :  :
  288. list of statements
  289.  :  :
  290. UNTIL condition
  291.  
  292. REPEAT...UNTIL is similar to WHILE...WEND except that the test
  293. completion is made at the end of the loop rather than the beginning.
  294. The loop will be repeated continually until the specified condition is
  295. FALSE. So it will always be performed at least once in your program.
  296. Example:
  297.  
  298.         Repeat
  299.           Print "AMOS Basic"
  300.         Until Mouse Key<>0
  301.  
  302.  
  303.  
  304.                        DO...LOOP (loop forever)                             79
  305.  
  306. DO
  307. :  :
  308. list of statements
  309. :  :
  310. LOOP
  311.  
  312. The DO...LOOP commands take a list of Basic statements and repeat them
  313. continually. In order to exit from this loop, you'll need to use a
  314. special EXIT or EXIT IF instruction.
  315.  
  316. The advantage of this system is that it's a structure alternative to
  317. the GOTO loops that tend to crop up in earlier versions of Basic. Take
  318. the following example:
  319.  
  320.         TEST:
  321.         Input "Another game (Y/N)";AN$
  322.         If Upper$(AN$)="N" Then Goto BYE
  323.         GAME : Rem call play game procedure
  324.         Goto TEST
  325.         BYE:
  326.         End
  327.  
  328. Now a second version using DO...LOOP
  329.  
  330.         Do
  331.           INput "Another game (Y/N)";AN$
  332.           Exit If Upper$(AN$)="N"
  333.           GAME : Rem call play game procedure
  334.         Loop
  335.         End
  336.  
  337.  
  338.  
  339.                      EXIT (Exit from a DO...LOOP)
  340.  
  341. EXIT [n]
  342.  
  343. The EXIT command exits immediately from one ore more program loops
  344. created with the FOR...NEXT, REPEAT...UNTIL, WHILE...WEND, or DO...LOOP
  345. statements. Your AMOS program will now jump directly to the next
  346. instruction after the current loop. 
  347.  
  348.   "n" is the numver of loops you wish to leave. If it's omitted, then
  349. only the innermost loop will be terminated.
  350.  
  351.  
  352.  
  353.             EXIT IF (Exit from a loop depending on a test)                  80
  354.  
  355. EXIT IF expression[,n]
  356.  
  357. "expression" consistes of a series of tests in the standard AMOS
  358. format. The EXIT will only be performed if the result evaluates to -1.
  359.  
  360.   The "n" parameter works the same way as using EXIT command.
  361.  
  362.  
  363.  
  364.            EDIT (stop running the prog and return to Editor)
  365.  
  366. EDIT
  367.  
  368. The EDIT directive stops the current program and returns to the AMOS
  369. Basic editor. This can be very useful when you are debugging one of
  370. your progs.
  371.  
  372.  
  373.  
  374.                      DIRECT (exit to direct mode)
  375.  
  376. DIRECT
  377.  
  378. Terminates your program and jumps to the direct mode immediately. You
  379. can now examine the contents of your variables or list your programs
  380. out to the printer.
  381.  
  382.  
  383.  
  384.                       END (Exit from the program)                           81
  385.  
  386. END
  387.  
  388. This instruction exits from a program. You'll now be given the option
  389. to return to either the editor or to direct mode.
  390.  
  391.  
  392.  
  393.                    ON...PROC (jump to one of several
  394.                   procedures depending on a variable)
  395.  
  396. ON v PROC proc1, proc2, proc3, ...procN
  397.  
  398. Jumps to a named procedure depending on the contents of variable v.
  399. Note that any procedures you use in this command CANNOT include
  400. parameters. If you need to transfer information to this procedure, you
  401. should place them in *global* variables instead. See PROCEDURES for a
  402. full explanation of this technique. 
  403.  
  404.   The ON...PROC command is effectively equivalent to the following:
  405.  
  406.         If v=1 Then Proc1
  407.         If v=2 Then Proc2
  408.           :    :
  409.         If v=n Then ProcN
  410.  
  411.  
  412.  
  413.                ON...GOTO (jump to one of a list of lines
  414.                        depending on a variable)
  415.  
  416. ON v GOTO line1, line2, line3, ...lineN
  417.  
  418. The ON GOTO instruction lets your program jump to one of a number of
  419. lines depending on the result of an expression in v. It's equivalent to
  420. the following lines:
  421.  
  422.         If v=1 Then Goto Line1
  423.         If v=2 Then Goto Line2
  424.           :     :
  425.         If v=n Then Goto LineN
  426.  
  427.  
  428.  
  429.                   ON...GOSUB (GOSUB one of a list of
  430.                        routines dependig on var)
  431.  
  432. ON var GOSUB line1, line2, line3, ...
  433.  
  434. This is identical to ON...GOTO except it uses a gosub rather than a
  435. goto to jump the line.
  436.  
  437.  
  438.  
  439.         EVERY n GOSUB (call a subroutine at regural intervals)              82
  440.  
  441. EVERY n GOSUB label
  442.  
  443. The ON EVERY statement calls the subroutine at label at regural
  444. intervals, without interfering with your main program. 
  445.  
  446.   "n" is the length of your interval in 50ths of a second. The time
  447. taken for your subroutine to complete must always be less than this
  448. period, or you'll get an error.
  449.  
  450.   After a subroutine has been entered, the system will automatically
  451. disabled. In order to call this feature continuously, you'll therefore
  452. need to add EVERY ON command before the final RETURN statement ;
  453.  
  454.         Every 50 Gosub TEST
  455.         Do
  456.           Print "Main loop"
  457.         Loop
  458.         TEST:
  459.         Inc I : Print "This is call number ";I
  460.         Every On:Return
  461.  
  462.  
  463.  
  464.          EVERY n PROC (call a procedure at regural intervals)
  465.  
  466. EVERY n PROC name
  467.  
  468. EVERY PROC execute the required procedure automatically at regular
  469. intervals using a powerful interrupt system.
  470.  
  471.   "n" is the delay between each successive procedure call measured in
  472. units of a 50th of a second.
  473.  
  474.   As with the previous command, the interrupt must be reactivated
  475. before leaving your procedure, otherwise the routine will only be
  476. called just once. So you'll need to use EVERY ON before returning to
  477. your main program with END PROC ;
  478.  
  479.         Every 50 Proc TEST
  480.         Do
  481.           Print "Main loop"
  482.         Loop
  483.         Procedure TEST
  484.           Shared I
  485.           Inc I : Print "This is call number ";I
  486.           Every On
  487.         End Proc
  488.  
  489.  
  490.  
  491.             EVERY ON/OFF (toggle automatic procedure calls)
  492.  
  493. EVERY ON/OFF
  494.  
  495. EVERY ON restarts the interrupt system used by the EVERY commands. It
  496. should be called just before the procedure or subroutine has finished
  497. executing.
  498.  
  499. EVERY OFF disables the calls completely. It's automatically executed at
  500. the start of one of these procedures.
  501.  
  502.  
  503.  
  504.             BREAK ON/OFF (turn on/off the CTRL+C Break key)                 83
  505.  
  506. BREAK ON/OFF
  507.  
  508. Normally you can interrupt a program and return to Basic at any time by
  509. simply pressing CTRL+C. This function can be deactivated using the
  510. BREAK OFF command. You can restart the Break keys using BREAK ON
  511.  
  512.  
  513.  
  514. Error handling
  515. ==============
  516.  
  517.  
  518.            ON ERROR GOTO (trap an error within a Basic prog)
  519.  
  520. ON ERROR GOTO label
  521.  
  522. This command allows you to detect and correct the errors inside an AMOS
  523. Basic program, without having to return to the editor window.
  524. Sometimes, errors can arise in a program which are impossible to
  525. predict in advance. Take, for instance, the following routine:
  526.  
  527.         Do
  528.           Input "Enter two numbers";A,B
  529.           Print A;" divided by ";B;" is ";A/B
  530.         Loop
  531.  
  532. This program works fine until you try to enter a zero for B. You can
  533. avoid the "division by zero error" by trapping the error with an ON
  534. ERROR GOTO instruction like so:
  535.  
  536.         ON ERROR GOTO label
  537.  
  538. Whenever an error occurs in your Basic program, AMOS will now jump
  539. straight to "label". This will be the starting point of your own error
  540. correction routine which can fix the error and safely return to your
  541. main program.
  542.  
  543.   Note that error handler MUST exit using a special RESUME instruction.
  544. You are not allowed to jump back to your program with a normal GOTO
  545. statement.
  546.  
  547.         On Error Goto HELP
  548.         Do
  549.           Input "Enter two numbers";A,B
  550.           Print A;" divided by ";B;" is ";A/B
  551.         Loop
  552.         HELP:
  553.         Print : Print : Bell
  554.         Print "I'm afraid you've attempted to divide with zero!"
  555.         Resume Next: Rem Return back to the next instruction.
  556.  
  557. In order for this system to work, it's essential that an error does not
  558. arise inside your error correction routine, otherwise AMOS will halt
  559. your program ignominiously.
  560.  
  561.   The action of ON ERROR GOTO can be disabled by calling ON ERROR with
  562. no parameters.
  563.  
  564.         On Error : Rem Kill error traps
  565.  
  566.  
  567.  
  568.             ON ERROR PROC (Trap an error using a procedure)                 84
  569.  
  570. ON ERROR PROC name
  571.  
  572. Selects a procedure which will be called automatically if there's an
  573. error in the main program. It's really just a structured version of the
  574. ON ERROR GOTO statement. 
  575.  
  576.   Although your procedure must be terminated by and END PROC in the
  577. normal way, you'll need to return to your main program with an
  578. additional call to RESUME. This can be placed just before the final END
  579. PROC statement. 
  580.  
  581.  
  582.  
  583.                 RESUME (resume execution of the program                     85
  584.                             after an error)
  585.  
  586. There are five possible formats of this instruction:
  587.  
  588.         RESUME
  589.  
  590. Jumps back to the statement which caused the error and tries again.
  591.  
  592.         RESUME NEXT
  593.  
  594. Returns to the instruction just after the one which caused the error.
  595.  
  596.         RESUME LINE
  597.  
  598. Jumps to as specific line point in your main program. "line" can refer
  599. to either a label or a normal line number. This may *NOT* be used to
  600. re-enter a procedure!
  601.  
  602.   Procedures are treated slightly differently. If you want to jump to a
  603. particular label, you have to place a special marker somewhere in the
  604. procedure you are checking for errors. This may be accomplished using
  605. the RESUME LABEL command. There are two separate versions.
  606.  
  607.         RESUME LABEL label
  608.  
  609. Defines the label which is to be returned after an error. This must be
  610. called outside your error handler just after the original ON ERROR PROC
  611. or ON ERROR GOTO statement. 
  612.  
  613.         RESUME LABEL
  614.  
  615. Used inside your error handler to jump straight back to the label
  616. you've set up with the previous command. Example:
  617.  
  618.         On Error Proc HELP
  619.         Resume Label AFTER
  620.         Error 12
  621.         Print "Never Printed"
  622.         AFTER : Print "I've returned here"
  623.         End
  624.         Procedure HELP
  625.           Print "Oh Dear, I think there's an error!"
  626.           Resume Label
  627.         Endproc
  628.  
  629.  
  630.  
  631.                 =ERRN (return the number of last error)
  632.  
  633. e=ERRN
  634.  
  635. If you're creating your own error handling routines using the ON ERROR
  636. command, you'll need to be able to check precisely which error has
  637. occurred in the main program. 
  638.  
  639.   When an error occurs, ERRN is automatically loaded with its
  640. identification number. See the Apeendix at the end of this manual for a
  641. full list of the possible errors.
  642.  
  643.         Print ERRN
  644.  
  645.  
  646.  
  647.           ERROR (generate an error and return to the Editor)
  648.  
  649. ERROR n
  650.  
  651. The action of the ERROR command is to actually generate an error.
  652. Supposing you have created a nice little error handling routine which
  653. is able to cope with all possible disc errors. ERROR provides you with
  654. a simple way of simulating all the various problems, without the
  655. inconvenience of the actual error. Example:
  656.  
  657.         Error 40
  658.  
  659. Quits the program and prints out a "Label not defined" error.
  660.  
  661.         Error Errn
  662.  
  663. This uses the ERRN function to print the current error condition after
  664. a problem in your program.
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.                           8: TEXT AND WINDOWS                               87
  673.                       ---------------------------
  674.  
  675. Text Attributes
  676. ===============
  677.  
  678.                        PEN (set colour of text)
  679.  
  680. PEN index
  681.  
  682. The PEN instruction sets the colour of all the text which will be
  683. displayed in the current window. This colour can be chosen from one up
  684. to 64 different possibilities depending on the gfx mode you're using.
  685. Example:
  686.           PEN 6
  687.  
  688.  
  689.  
  690.           =PEN$(n) (change the pen colour using ctrl chrars)
  691.  
  692. a$=PEN$(n)
  693.  
  694. PEN$ returns a special control sequence which changes the pen colour
  695. inside a string. The new pen colour will be automatically assigned
  696. whenever this string is subsequently printed on the screen. Example:
  697.  
  698.         C$=Pen$(2)+"White "+Pen$(6)+"Blue"
  699.         Print C$
  700.  
  701. The string returned by PEN$ is in the format:
  702.  Chr$(27)+"P"+Chr$(48+n)
  703.  
  704.  
  705.  
  706.                PAPER (set colour of the text background)
  707.  
  708. PAPER index
  709.  
  710. "index" can be a number between 0-63.
  711.  
  712.  
  713.  
  714.                =PAPER$(n) (return a control sequence to                     88
  715.                          set the paper colour)
  716.  
  717. x$=PAPER$(index)
  718.  
  719. PAPER$ returns a character string which automatically changes the
  720. background colour when it's printed on the screen. For example:
  721.  
  722.         Pen 1: C$=Paper$(2)+"White "+Paper$(6)+"Blue"
  723.         Print C$
  724.  
  725.  
  726.  
  727.                   INVERSE ON/OFF (enter inverse mode)
  728.  
  729. INVERSE ON/OFF
  730.  
  731. The INVERSE command swaps the text and the background colours.
  732.  
  733.  
  734.  
  735.                SHADE ON/OFF (shade all subsequent text)
  736.  
  737. SHADE ON/OFF
  738.  
  739. SHADE ON highlights your text by reducing the brightness of the
  740. characters with a mask pattern. The shade of your text can be returned
  741. to normal using SHADE OFF
  742.  
  743.  
  744.  
  745.                    UNDER ON/OFF (set underline mode)                        89
  746.  
  747. UNDER ON/OFF
  748.  
  749. UNDER ON underlines your text when it's printed on the screen. UNDER
  750. OFF turns off the mode.
  751.  
  752.  
  753.  
  754.                   WRITING (change text writing mode)
  755.  
  756. WRITING w1 [,w2]
  757.  
  758. The WRITING command allows you to change the writing mode used for all
  759. subsequent text operations. This determines precisely how your new text
  760. will be combined with the existing screen data.
  761.  
  762.         w1=0   REPLACE (Default)   Your new text will obliterate
  763.                                    anything underneath it.
  764.         w1=1   OR                  Merges the characters onto the
  765.                                    screen with a logical OR.
  766.         w1=2   XOR                 Chars are combined now with XOR.
  767.  
  768.         w1=3   IGNORE              Printing operations are ignored!
  769.  
  770. The secont number chooses which parts of the text will be printed on
  771. the screen. This option can be omitted if required.
  772.  
  773.         w2=0   Normal       The text is output to the screen along with 
  774.                             the background.
  775.         w2=1   Paper        Only the background of the text is drawn on
  776.                             the screen.
  777.         w2=2   Pen          Ignores the paper colour and writes the
  778.                             text on a background of colour zero.
  779.  
  780. Do *NOT* confuse this with GR WRITING!
  781.  
  782.  
  783.  
  784. Cursor functions
  785. ================
  786. AMOS includes a range of facilities which let you move cursor to any
  787. part on the screen.
  788.  
  789.  
  790.  
  791.                      LOCATE (position the cursor)                           90
  792.  
  793. LOCATE x,y
  794. LOCATE x,         Locate moves the text cursor to the coordinates x,y.
  795. LOCATE ,y         This sets the starting point for all future printing
  796.                   operations. All screen positions are specified using
  797. a special set of text coordinates. These are meadured in units of a
  798. single character relative to the top left corner of the text window.
  799. For instance the coordinates 15,10 refer to a point 10 chars down and
  800. 15 to the right.
  801.  
  802.   If you attempt to print something outside window limits an error will
  803. be generated.
  804.  
  805.   Note that the current screen is always treated as window 0. So you
  806. don't have to actually open a window before using one of these
  807. functions. 
  808.  
  809.  
  810.  
  811.                    CMOVE (relative cursor movement)
  812.  
  813. CMOVE w,h
  814.  
  815. Moves the cursor a fixed distance away from its present position. If
  816. your cursor was at 10,10, then typing:
  817.  
  818.         CMOVE 5,-5
  819.  
  820. would move the cursor to 15,5. Like LOCATE you can omit either one of
  821. the coordinates as required.
  822.  
  823.  
  824.  
  825.                  =AT (return a sequence of ctrl chars                       91
  826.                         to position the cursor)
  827.  
  828. x$=AT(x,y)
  829.  
  830. The AT function allows you to change the position of text directly from
  831. inside a character string. It works by returning a string in the
  832. format:
  833.           Chr$(27)+"X"+Chr$(27)+"Y"+Chr$(48+Y)
  834.  
  835. Whenever this string is printed, the text cursor will be moved to the
  836. coordinates x,y. For example:
  837.  
  838.       A$="This"+At(10,10)+"Is"+At(1,2)+"The Power Of"+At(20,20)+"AMOS!"
  839.       Print A$
  840.  
  841. These AT commands are perfect for hi-score tables as they allow you to
  842. position our text once and for all during your programs initialisation
  843. phase. You can now update the score at the correct point on the screen
  844. using a single print statement. Here's an example:
  845.  
  846.         HI_SCORE$=At(20,10)+"Hi Score "
  847.         SCORE=10000
  848.         Print HI_SCORE$;SCORE
  849.  
  850.  
  851.  
  852. Conversion functions
  853. ====================
  854. AMOS Basic provides you with four useful functions which readliy enable
  855. you to convert between text and graphics coordinates.
  856.  
  857.  
  858.  
  859.            =XTEXT (convert an x coordinate gfx->text format)                92
  860.            =YTEXT (convert an y coordinate gfx->text format)
  861.  
  862. t=XTEXT(x)
  863. t=YTEXT(y)
  864.  
  865. These functions take normal x/y coordinates and convert them to text
  866. coordinates relative to the current window. If the screen coordinate
  867. lies outside this window then a negative value will be returned. See
  868. EXAMPLE 8.1.
  869.  
  870.  
  871.  
  872.          =XGRAPHIC (convert an x coordinate text->gfx format)
  873.          =YGRAPHIC (convert an y coordinate text->gfx format)
  874.  
  875. g=XGRAPHIC(x)
  876. g=XGRAPHIC(y)
  877.  
  878. These functions are effectively the inverse of XTEXT and YTEXT in that
  879. they take a text X (or) Y coordinate ranging from 0 to the width/height
  880. of the current window and convert them to absolute screen coordinates.
  881. See EXAMPLE 8.2
  882.  
  883.  
  884. Cursor commands
  885. ===============
  886. The text cursor serves as a visible starting point of all future text
  887. operations. It's usually displayed as a flashing horizontal bar,
  888. although this may be changed using the SET CURS and CURS OFF commands.
  889.  
  890.   By moving the cursor on the screen, you can position your text
  891. practically anywhere you like. Remember, all coordinate measurements
  892. are taken using TEXT coordinates relative to the current window.
  893.  
  894.  
  895.  
  896.                           HOME (cursor home)
  897.  
  898. HOME
  899.  
  900. Moves the text cursor to the top left hand corner of the current window
  901. (coordinates 0,0)
  902.  
  903.  
  904.  
  905.                           CDOWN (cursor down)                               93
  906. CDOWN
  907.  
  908. Pushes the text cursor down by a single line.
  909.  
  910.  
  911.  
  912.                  =CDOWN$ (return a Chr$(31) character)
  913. x$=CDOWN$
  914.  
  915. CDOWN$ is a function which returns a special control character which
  916. automatically moves the cursor when it is printed. So Print CDOWN$ is
  917. identical to CDOWN. CDOWN$ allows you to combine several cursor
  918. movements in a single string. For example:
  919.  
  920.         C$="\"+Cdown$
  921.         For A=0 to 20
  922.           Print C$;
  923.         Next A
  924.  
  925.  
  926.                             CUP (cursor up)
  927. CUP
  928.  
  929. Moves the text cursor up a line in the same way that CDOWN moves down.
  930.  
  931.  
  932.  
  933.                   =CUP$ (return a Chr$(30) character)
  934. x$=CUP$
  935.  
  936. CUP$ returns a control string which moves the cursor up by a single
  937. character.
  938.  
  939.  
  940.                           CLEFT (cursor left)                               94
  941. CLEFT
  942.  
  943. Displaces the text cursor one character to the left. 
  944.  
  945.  
  946.  
  947.               =CLEFT$ (Control string for CLEFT Chr$(29))
  948. x$=CLEFT$
  949.  
  950. Moves the text cursor one character left. Works like =CUP$.
  951.  
  952.  
  953.  
  954.                          CRIGHT (cursor right)
  955. CRIGHT
  956.  
  957. Moves cursor one place to the right.
  958.  
  959.  
  960.  
  961.        =CRIGHT$ (Generate a Chr$(28) control string for CRIGHT)
  962.  
  963. x$=CRIGHT$
  964.  
  965. Is the opposite of CLEFT$.
  966.  
  967.  
  968.  
  969.           XCURS (return the X coordinate of the text cursor)
  970.           YCURS (return the Y coordinate of the text cursor)                95
  971.  
  972. x=XCURS
  973. y=YCURS
  974.  
  975. XCURS is a variable containing the current X coordinate of the text
  976. cursos (in text format). YCURS holds the Y coordinate of the cursor.
  977.  
  978.  
  979.  
  980.                    SET CURS (set text cursor shape)
  981.  
  982. SET CURS L1,L2,L3,L4,L5,L6,L7,L8
  983.  
  984. This instructoin allows you to change the shape of the cursor to
  985. anything you like. The shape is specified by a list of bit-patterns
  986. held in the parameters L1-L8, Each parameter determines the appearance
  987. of the horizontal line of the cursor, numbered from top to bottom.
  988.  
  989.   Every bit represnts a single point in the current cursor line. If
  990. it's set to 1 then the point will be drawn using colour number 3 -
  991. otherwise it will be displayed in the current PAPER colours. Example:
  992.  
  993.         L1=%11111111
  994.         L2=%11111110
  995.         L3=%11111100
  996.         L4=%11111000
  997.         L5=%11110000
  998.         L6=%11100000
  999.         L7=%11000000
  1000.         L8=%10000000
  1001.         Set Curs L1,L2,L3,L4,L5,L6,L7,L8
  1002.  
  1003.  
  1004.  
  1005.                CURS ON/OFF (enable/disable text cursor)
  1006.  
  1007. CURS ON                          makes text cursor visible
  1008. CURS OFF                         hides the cursor in current window
  1009.  
  1010.  
  1011.  
  1012.                      MEMORIZE X/Y (save the X or Y
  1013.                     coordinates of the text cursor)
  1014. MEMORIZE X
  1015. MEMORIZE Y
  1016.                The Memorize commands store the current cursor position.
  1017.  
  1018.  
  1019.  
  1020.                    REMEMBER X/Y (restore the X or Y                         96
  1021.                     coordinate of the text cursor)
  1022. REMEMBER X
  1023. REMEMBER Y
  1024.                REMEMBER positions the cursor at the coordinates saved
  1025.                by a previous call to MEMORIZE. If MEMORIZE has not been
  1026.           used then the coordinates will be set to zero. See EXAMPLE 8.3
  1027.  
  1028.  
  1029.  
  1030.          CLINE (clear part or all of the current cursor line)
  1031.  
  1032. CLINE [n]
  1033.  
  1034. Clears the line on which the cursor is positioned. If n is present then
  1035. "n" characters are cleared starting at the current cursor position.
  1036.  
  1037.  
  1038.  
  1039.           CURS PEN (choose a new colour for the text cursor)
  1040.  
  1041. CURS PEN n
  1042.  
  1043. Changes the colour of the text cursor to index number n. 
  1044.  
  1045.  
  1046.  
  1047. Text Input/Output
  1048. =================
  1049.  
  1050.  
  1051.           CENTRE (print a line of text centred on the screen)
  1052.  
  1053. CENTRE a$
  1054.  
  1055. Takes a string of characters in a$ and prints it in the centre of the
  1056. screen. This text is always output on the current cursor line. 
  1057.  
  1058.         Locate 0,1
  1059.         Centre "This is a centered TITLE"
  1060.  
  1061.  
  1062.  
  1063.                        =TAB$ (print tabulation)                             97
  1064.  
  1065. x$=TAB$
  1066.  
  1067. TAB$ returns a control character known as a TAB (Ascii 9). When this
  1068. character is printed the text cursor will be immediately moved several
  1069. places to the right. The size of this movement can be set using the SET
  1070. TAB kommand. As a default, the tab spacing is set to four (4).
  1071.  
  1072.  
  1073.  
  1074.                     SET TAB (change the tabulation)
  1075.  
  1076. SET TAB n
  1077.  
  1078. This specifies the distance the text cursor will move when TAB
  1079. character is printed.
  1080.  
  1081.  
  1082.  
  1083.                         REPEAT$ (repeat string)
  1084.  
  1085. x$=REPEAT$(a$,n)
  1086.  
  1087. The REPEAT$ function allows you to print out the same string of
  1088. characters several times using a single PRINT statement. 
  1089.  
  1090.   It works by adding a sequenve of control characters into variable X$.
  1091. When this string is printed, AMOS simply repeats a$ to the screen n
  1092. times. Possible values for n range between 1 and 207. See EXAMPLE 8.4.
  1093.  
  1094. The format of the control string is:
  1095.  
  1096.         Chr$(27)+"RO"+A$+Chr$(27)+"R"+Chr$(48+n)
  1097.  
  1098.  
  1099. Advanced Text Commands                                                      98
  1100. ======================
  1101.  
  1102.  
  1103.              ZONE$ (set up a zone around a piece of text)
  1104.  
  1105. x$=ZONE$(a$,n)
  1106.  
  1107. The ZONE$ function surrounds a section of text with a screen zone.
  1108. After you have defined one of these zones you can check for coillisions
  1109. between the zone and the mouse using the ZONE function. This allows you
  1110. to create powerful on-screen menus and dialogue boxes without having to
  1111. resort to any complicated programming tricks.
  1112.  
  1113.   a$ is a string containing the text for one the "Buttons" in your
  1114. dialogue box. This button will be activated automatically when you
  1115. print x$ to the screen.
  1116.  
  1117.   n specifies the number of screen zone to be defined. The max. number
  1118. of these zones depends on the value you specified with RESERVE ZONE.
  1119.  
  1120.   See the EXAMPLE 8.5 program in the MANUAL folder. The format of the
  1121. control string is:
  1122.                    Chr$(27)+"ZO"+A$+Chr$(27)+"R"+Chr$(48+n)
  1123.  
  1124.  
  1125.  
  1126.                   BORDER$ (add a border to some text)
  1127.  
  1128. x$=BORDER$(a$,n)
  1129.  
  1130. This returns a string of control characters which instructs AMOS to
  1131. draw a border aound the required text. It's commonly used in
  1132. conjunction with the ZONE$ command to produve the fancy buttons found
  1133. in dialogue boxes and alert windows.
  1134.  
  1135.   n is the border number ranging from 1 to 16 and a$ holds the text to
  1136. be enclosed by the border. The text in a$ will start at the current
  1137. cursor position so don't be surprised when you get strange results
  1138. printing at 0,0. To create a screen zone by a border try this:
  1139.  
  1140.         Print Border$(Zone$(" CLICK HERE ",1),2)
  1141.  
  1142. This would enclose the text with zone number 1 and border 2. The
  1143. control sequence is:
  1144.                      Chr$(27)+"EO"+A$+Chr$(27)+"R"+Chr$(48+n)
  1145.  
  1146.  
  1147.  
  1148.                   HSCROLL (horizontal text scrolling)
  1149.  
  1150. HSCROLL n
  1151.  
  1152. This scrolls all the text in the currently open window horizontally by
  1153. a single character position. n can take the following values:
  1154.  
  1155.         1 = Move current line to the left
  1156.         2 = Scrolls entire screen to the left
  1157.         3 = Move current line to the right
  1158.         4 = Move screen to the right
  1159.  
  1160.  
  1161.  
  1162.                        VSCROLL (vertival scroll)                            99
  1163.  
  1164. VSCROLL n
  1165.  
  1166. Scrolls the text in the currently open window vertically.
  1167.  
  1168.         1 = Any text at the cursor line and below is scrolled down
  1169.         2 = Text at cursor line or below is moved up
  1170.         3 = Only text from the top of the screen to the cursor line
  1171.              is scrolled up
  1172.         4 = Text from top of the screen to the current cursor position 
  1173.              is scrolled down       
  1174.                                               Blank lines are inserted
  1175.                      to pad out the gap left by the scrollingoperation.
  1176.  
  1177.  
  1178.  
  1179. Windows
  1180. =======
  1181. The AMOS windowing commands allow you to restrict your text and
  1182. graphics operations just a part of the current screen.
  1183.  
  1184.   AMOS windows can be used with the zone commands to produce effective
  1185. dialogue boxes such as file selectors and high score tables. A typical
  1186. warning box, for instance, can be easily generated with just a couple
  1187. lines of AMOS Basic.
  1188.  
  1189.  
  1190.  
  1191.                       WINDOPEN (create a window)
  1192.  
  1193. WINDOPEN n, x, y, w, h [,border [,set]]
  1194.  
  1195. The WINDOPEN instruction opens a window and displays it on the screen.
  1196. This window will now be used for all subsequent text operations.
  1197.  
  1198.   n is the number of the window to be defined. AMOS allows you to
  1199. create as many windows as you like, limited only by the amount of
  1200. available memory. As a default, window number zero is assigned to the
  1201. current screen. So don't attempt to re-open this window using WINDOPEN
  1202. or change it with WIND SIZE or WIND MOVE.
  1203.  
  1204.   x,y are the graphics coordinates of the top left hand corner of your
  1205. new window. Since AMOS windows are drawn using the Amiga's blitter
  1206. chip, the window area must always lie on a 16-pixel boundary. In order
  1207. to achieve this, the x coordinates are automatically rounded to the
  1208. nearest multiple of 16. Additionally, if you've included a border for
  1209. your window, the X coordinate will be incremented by a further eight.
  1210. This will ensure that the working area of your window always starts at
  1211. the correct screen boundary. There are no restrictions whatsoever on
  1212. the y coordinates.
  1213.  
  1214.   w,h specify the size in characters of the new window. These              100
  1215. dimensios must always be divisible by 2.
  1216.  
  1217.   "border" selects a border style for your window. There are 16
  1218. possible styles, with values ranging between 1 and 16.
  1219.  
  1220.   Window borders can also include up to two optional title lines. One
  1221. title is displayed along the top of the window and another may be added
  1222. at the bottom.
  1223.  
  1224.   AMOS windows may contain either text or graphics, just like the
  1225. intuition system. Each window can be assigned it's own individual
  1226. character set with the powerful WINDOW FONT command. There's also a
  1227. powerful WIND SAVE instuction which saves the screen area inside your
  1228. windows. Whenever you move one of these windows the contents underneath
  1229. will be automatically redrawn. For example:
  1230.  
  1231.         For W=1 To 3
  1232.           Windopen W,(W-1)*96,50,10,101
  1233.           Paper W+3 : Pen W+6 : Clw
  1234.           Print "Window ";W
  1235.         Next W
  1236.  
  1237. You can flick between these windows using the WINDOW command. Try
  1238. typing the following statements from the Direct mode:
  1239.  
  1240.         Window 1 : Print "AMOS"
  1241.         Window 3 : Print "in action!"
  1242.         Window 2 : Print "Basic"
  1243.  
  1244. The active window can always be distinguished by a flashing cursor -
  1245. through this can be turned off using the CURS OFF command if required.
  1246.  
  1247.  
  1248.  
  1249.                    WINDOW FONT (change window font)
  1250.  
  1251. WINDOW FONT n
  1252.  
  1253. Changes the font used by the current window to set n. n is the number
  1254. of a graphics font which has been previously installed with the GET
  1255. FONT command. This font *must* have dimensions of exactly 8x8.
  1256. Proportional fonts are not allowed.
  1257.  
  1258.   Since the window vborders make use of some of these characters, you
  1259. may get rather odd results when you're using standard WBench fonts.
  1260.  
  1261.  
  1262.  
  1263.           WIND SAVE (save the contents of the current window)
  1264.  
  1265. WIND SAVE
  1266.  
  1267. The WIND SAVE command allows you to move your windows anywhere on the
  1268. screen without corrputing your existing display.
  1269.  
  1270.   Once you've activated this feature, any windows you subsequently open
  1271. will automatically save the entire contents of the windows underneath.
  1272. This area will be redrawn whenever you close a window or move it to a
  1273. new position.
  1274.  
  1275.   It's important to note that this option saves the contents of the
  1276. current window, rather than the one you are defining with WIND OPEN.
  1277.  
  1278.   At the start of your program the current window will be the default
  1279. screen and will take up a massive 32k of memory. If you wished to save
  1280. the background underneath a dialogue box the most of this memory would
  1281. be completely wasted.
  1282.  
  1283.   The solution is to create a dummy window of the required size, and to
  1284. position it over the zone you wish to save. You can now execute a WIND
  1285. SAVE command and continue with your program as normal.
  1286.  
  1287.   When you subsequently call up your dialogue box the area underneath
  1288. will be saved as part of your dummy window. So it will be automatically
  1289. restored after your box has been removed.
  1290.  
  1291.  
  1292.  
  1293.                BORDER (change the window border of the)                    101
  1294.                             current screen)
  1295.  
  1296. BORDER n,paper,pen
  1297.  
  1298. The BORDER command sets the border of the current window to style
  1299. number n. This border is drawn using a group of characters installed in
  1300. the default font. It is therefore possible to create your own border
  1301. styles using the font definer accessory.
  1302.  
  1303.   The paper and pen options allow you to freely choose the colours of
  1304. your border. Acceptable border numbers range from 1 to 16.
  1305.  
  1306.   Any of the parameters may be omitted from this instuction so the
  1307. following commands are legal:
  1308.  
  1309.         BORDER 2,,
  1310.         BORDER 2,,3
  1311.  
  1312.  
  1313.  
  1314.                  TITLE TOP (define the upper title for
  1315.                           the current window)
  1316.  
  1317. TITLE TOP t$ 
  1318.  
  1319. This instruction sets the top line of the current window to the title
  1320. string in t$. Only bordered windows may be titled in this way.
  1321.  
  1322.         Windopen 5,1,1,20,10
  1323.         Title Top "Window Number 5"
  1324.         Wait Key
  1325.  
  1326.  
  1327.  
  1328.                TITLE BOTTOM (define the lower title for
  1329.                           the current window)
  1330.  
  1331. TITLE BOTTOM b$
  1332.  
  1333. This command assigns the string b$ to the bottom title of the current
  1334. window.
  1335.  
  1336.  
  1337.  
  1338.                       WINDOW (change current window)                       102
  1339.  
  1340. WINDOW n
  1341.  
  1342. WINDOW activates the window n as the current window. If the automatic 
  1343. saving system has been initiated, this window be immediately redrawn
  1344. along with any of its contents. See EXAMPLE 8.6 in the Manual folder.
  1345.  
  1346.  
  1347.  
  1348.                =WINDON (Return the value current window)
  1349.  
  1350. w=WINDOW
  1351.  
  1352. WINDON returns the identification number of the currently active
  1353. window.
  1354.  
  1355.  
  1356.  
  1357.                  WIND CLOSE (close the current window)
  1358.  
  1359. WIND CLOSE
  1360.  
  1361. Deletes the current window. Use the WIND SAVE command if you want the
  1362. area that was hidden be redrawn by.
  1363.  
  1364.  
  1365.  
  1366.                        WIND MOVE (move a window)
  1367.  
  1368. WINDMOVE x,y
  1369.  
  1370. Windmove moves the current window to graphics coordinates x,y. As with
  1371. the original window definitions the x coordinate will be rounded to the
  1372. nearest 16-pixel boundary.
  1373.  
  1374.  
  1375.  
  1376.            WIND SIZE (change the size of the current window)               103
  1377.  
  1378. WIND SIZE sx,sy
  1379.  
  1380. This command changes the size of an AMOS window. The new sizes, sx and
  1381. sy, are specified in units of a single character. Sx must be divisible
  1382. by two. See EXAMPLE 8.7.  
  1383.  
  1384.   If you've previously called the WIND SAVE command, the original
  1385. contents of your window will be redrawn by this instruction. If the new
  1386. window is smaller than the original one, any parts of the image which
  1387. lie outside will be lost. Alternatively, if you've expanded your
  1388. window, the area around your saved region will be filled with the
  1389. current paper colour. Also note that after a WIND SIZE command the text
  1390. cursor is always reset to coordinates 0,0.
  1391.  
  1392.  
  1393.  
  1394.                     CLW (clear the current window)
  1395.  
  1396. CLW
  1397.  
  1398. Erases the contents of the current window and fills it with the current
  1399. PAPER colour.
  1400.  
  1401.  
  1402. Slider bars                                                                104
  1403. ===========
  1404. AMOS incorporates three insturctions which allow you to display a
  1405. standard slider bar on the screen. These sliders cannot be manipulated
  1406. directly with the mouse. In order to create a working slider bar,
  1407. you'll need to write a small Basic routine to perform this operate in
  1408. your main program. Due to the sheer power of the AMOS system, this is
  1409. extremely easy to accomplish, and the results can be extremely
  1410. impressive, as can be seen from EXAMPLE 8.8.
  1411.  
  1412.  
  1413.  
  1414.                   HSLIDER (draw a horizontal slider)
  1415.  
  1416. HSLIDER x1,y1 OT x2,y2,total,pos,size
  1417.  
  1418. Draws a horizontal slider bar from x1,y1 to x2,y2. "total" is the
  1419. number of individual units which the slider will be divided into. Each
  1420. unit represents a single item in the object you are controlling with
  1421. the slider. TSo in the editor window, "total" would be set to the
  1422. number of lines in the current program. The size of each unit is
  1423. calculated from the following formula:
  1424.  
  1425.         (X2-X1)/Total
  1426.  
  1427. "pos" is the position of the slider box from the start of the slider,
  1428. measured in the units you specified using "total". "size" is the length
  1429. of the slider box in the previous units. See EXAMPLE 8.9.
  1430.  
  1431.  
  1432.  
  1433.                    VSLIDER (draw a vertical slider)
  1434.  
  1435. VSLIDER x1,y1 TO x2,y2,total,pos,size
  1436.  
  1437. VSLIDER is almost identical to the previous HSLIDER insturction. It
  1438. displays a simple slider from x1,y1 to x2,y2. See EXAMPLE 8.10.
  1439.  
  1440.  
  1441.  
  1442.                   SET SLIDER (sets the fill patterns
  1443.                            used in a slider)
  1444.  
  1445. SET SLIDER b1,b2,b3,pb,s1,s2,s3,ps
  1446.  
  1447. Although this command looks incredibly complicated, it's actually
  1448. rather simple. SET SLIDER enters the colours and patterns to be used in
  1449. the slider bars created with the H/VSLIDER commands.
  1450.  
  1451.   "b1,b2,b3" set the ink, paper and outline colours for the background
  1452. of the box. "pb" chooses the fill pattern to be used for these regions.    105
  1453.  
  1454.   "s1,s2,s3" input the colours of the slider box, and "sp" selects the
  1455. pattern it is to be filled with.
  1456.  
  1457.   "bp" and "sp" can be any fill patterns you wish. As usual, negative
  1458. value refer to a sprite image from the current sprite bank. This allows
  1459. you to create amazing colorful slider boxes.
  1460.  
  1461.  
  1462. Fonts
  1463. =====
  1464. There are two different types of fonts available in AMOS - text fonts
  1465. and graphic fonts. The text fonts are those used by the PRINT and
  1466. WINDOW commands. Text fonts are known as character sets and each AMOS
  1467. Basic window can have its own individual set. The graphic fonts are
  1468. much more flexible and offer a wider range of styles:
  1469.  
  1470.  
  1471. Graphic text
  1472. ============
  1473. Your Amiga computer is capable of displaying an impressive variety of
  1474. different text styles. The original WorkBench disc was supplied with
  1475. eight attractive fonts in a range of sizes, and many more of these
  1476. fonts are freely available from the public domain. If you've upgraded
  1477. to WorkBench 1.3, you'll also be able to design your own fonts using
  1478. the FED program on the Extras disc.
  1479.  
  1480.   AMOS provides you with total support for these fonts. Text can be
  1481. printed in any of the available typefaces at any point on the screen.
  1482.  
  1483.   AMOS fonts can be used to add spice to even the most Basic games.
  1484. These are invaluable for producing the loading screens and hi-score
  1485. tables in your games. So it's a good idea to make full use of them in
  1486. your progs.
  1487.  
  1488.  
  1489.  
  1490.                       TEXT (print graphical text)                          106
  1491.  
  1492. TEXT x,y,t$
  1493.  
  1494. TEXT prints a line of text in t$ at graphical coordinates x,y. All
  1495. coordinates are measured relative to the characters baseline. This can
  1496. be determined using a special TEXT BASE function.
  1497.  
  1498.   Normally the baseline is positioned at the bottom of the character,
  1499. but some lowercase letters, such as "g", have a "tail" which extends
  1500. slightly below this point.
  1501.  
  1502.   As a default the type styles is set to eight-point Topaz. This may be
  1503. changed at any time using the SET FONT instruction. Try the following
  1504. program and notice how text can be placed at any pixel position on the
  1505. screen.
  1506.  
  1507.   Do
  1508.     Ink Rnd(15)+1,Rnd(15): Text Rnd(320)+1,Rnd(198)+1,"AMOS Basic"
  1509.   Loop
  1510.  
  1511. Al so notice how the colour of your text is set with INK rather than
  1512. the expected PEN and PAPER commands. This emphasizes the fact that the
  1513. TEXT command is basically a graphical instruction. So the control
  1514. sequences created by functions like CUP$ will be printed on the screen
  1515. instead of being correctly interpreted.
  1516.  
  1517.   There is no automatic line feed when the text reaches the end of the
  1518. current window. If you attempt to print something too large, the text
  1519. will be neatly clipped at the existing screen boundary. This can be
  1520. seen by the example below:
  1521.  
  1522.         Print String$("A",100):Text 0,100,String$("A",100)
  1523.  
  1524.  
  1525.  
  1526.            GET FONTS (create a list of all available fonts)
  1527.  
  1528. GET FONTS
  1529.  
  1530. The GET FONTS command creates an internal list of the all fonts
  1531. available from the current start-up disc. This list is essential to the
  1532. running of the SET FONT command, so you should always call GET FONTS at
  1533. least once before attempting to change the present font setting. The
  1534. contents of this list can be examined using the FONT$ function.
  1535.  
  1536.   WARNING! In order for GET FONTS to work, your current AMOS work disc
  1537. must always contain a copy of the standard LIBS folder along with its
  1538. contents. It's important to remember this fact when you are
  1539. distributing run-only or compiled programs because unless your discs
  1540. contain the required files, AMOS Basic will almost certainly crash!
  1541.  
  1542.  
  1543.  
  1544.            GET DISC FONTS (create a list of the disc fonts)                107
  1545.  
  1546. GET DISC FONTS
  1547.  
  1548. This command is identical to the previous GET FONTS instruction except
  1549. that it only searches for fonts on the disc. These fonts are contained
  1550. in the FONTS folder on your current boot-disc. If you want to use your
  1551. own fonts with AMOS basic, you'll need to copy these onto your normal
  1552. start-up disc. See the manual supplied with your Amiga for details of
  1553. this procedure.
  1554.  
  1555.  
  1556.  
  1557.             GET ROM FONTS (create a list of the rom fonts)
  1558.  
  1559. GET ROM FONTS produces a list of the fonts which are built into Amiga's
  1560. rom chips. At the present time there are just two of these fonts:
  1561. Eight-point Topaz and nine-point Topaz.
  1562.  
  1563.  
  1564.  
  1565.            =FONT$ (return details about the available fonts)
  1566.  
  1567. a$=FONT$(n)
  1568.  
  1569. Returns a string of 38 chars which describes font number n. This
  1570. function allows you to examine the font list created by a previous call
  1571. to one of the GET FONT commands. 
  1572.  
  1573.   a$ contains a list of characters which hold the name and type of your
  1574. font. If a font does not exist, a$ will be loaded a null value "",
  1575. otherwise a string will be returned in the following format:
  1576.  
  1577.         Character     Description                                          108
  1578.         ---------     -----------
  1579.            1-29       Font name
  1580.           30-33       Font height
  1581.           34-37       Identifier (set to either Disc or Rom)
  1582.  
  1583. See EXAMPLE 8.11!
  1584.  
  1585.  
  1586.  
  1587.                   SET FONT (choose a font for use by
  1588.                          the TEXT instruction)
  1589.  
  1590. SET FONT n
  1591.  
  1592. SET FONT changes the character set used by the TEXT command to font
  1593. number n. If the font is stored on the disc it will be automatically
  1594. loaded into your Amiga's memory. At the same time any previously sets
  1595. which are not in use will be removed. See EXAMPLE 8.12.
  1596.  
  1597.  
  1598.  
  1599.                        SET TEXT (set text style)
  1600.  
  1601. SET TEXT style
  1602.  
  1603. Allows you to change the style of a font. There are three styles to
  1604. choose from. "style" is a bit pattern in the following format:
  1605.  
  1606.         Bit  Effect
  1607.         ---  ------
  1608.          0   Underline        By setting the appropriate bits in this
  1609.          1   Bold             pattern you can choose between a total
  1610.          2   Italic           of eight different text styles.
  1611.  
  1612.  
  1613.  
  1614.               =TEXT STYLE (return the current text style)                  109
  1615.  
  1616. s=TEXT STYLE
  1617.  
  1618. This function returns the text style set from the SET TEXT command. The
  1619. result in "s" is a bit-map in the same format as that used by SET TEXT.
  1620.  
  1621.  
  1622.  
  1623.              =TEXT LENGTH (return the length of a section
  1624.                            of graphic text)
  1625.  
  1626. w=TEXT LENGTH(t$)
  1627.  
  1628. The TEXT LENGTH function returns the width in pixels of the character
  1629. string a$ in the current font. The width of a character varies
  1630. depending on the size of your fonts. In addition, proportional fonts
  1631. such as Helvetica assign different widths for each individual
  1632. character.
  1633.  
  1634.  
  1635.  
  1636.                =TEXT BASE (return the current text base)
  1637.  
  1638. b=TEXT BASE
  1639.  
  1640. This function returns the position of the baseline of your font. The
  1641. baseline is the number of pixels between the top of a character and
  1642. point it will be printed on the screen. It's basically similar to the
  1643. hot spot of a sprite or bob.
  1644.  
  1645.  
  1646. Installing new fonts
  1647. ====================
  1648. If you wish to use your own fonts within AMOS Basic, you'll need to
  1649. install them onto a copy of your AMOS program disc. The basic procedure
  1650. is as follows:
  1651.  
  1652.  - Copy the required font files into the FONTS: directory of your boot-
  1653.    disc.
  1654.  - Further information can be found in the Extra's manual supplied with 
  1655.    the Workbench 1.3 upgrade.
  1656.  
  1657.  
  1658. Troubleshooting
  1659. ===============
  1660.  
  1661. Problem:  GET FONTS seems to ignore any of the fonts on the current        110
  1662.           disc.
  1663. Solution: You've propably removed the original boot disc from your
  1664.           default drive. The Amiga's library routines expect to find
  1665.           the FONTS: directory on your start-up disc. This can be
  1666.           changed using the ASSIGN program in the UTILITIES folder.
  1667.  
  1668. Problem:  GET FONTS crahes the Amiga completely.
  1669. Solution: This problem can easily occur when you're creating programs
  1670.           in run-only or compiled format. GET FONTS requires the 
  1671.           discfont.library in the LIBS folder in order to work.
  1672.  
  1673. Problem:  The SET FONT command returns a "fonts not examined" error.
  1674. Solution: Add a cal to GET FONTS to the start of your program.
  1675.